<%--
  Created by IntelliJ IDEA.
  User: 70481
  Date: 2019/9/17
  Time: 13:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户信息统计</title>
</head>
<body>
<!-- 为 ECharts 准备一个具备大小（宽高）的 DOM -->
<div id="main" style="width: 600px;height:400px;"></div>
<div id="main2" style="width: 600px;height:400px;"></div>
<div id="main3" style="width: 600px;height:400px;"></div>
</body>

<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.12.4.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/echarts.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/js/china.js"></script>

<script type="text/javascript">

    $(function(){
        $.ajax({
            url:"${pageContext.request.contextPath}/user/selectUserDTO",
            success:function(data){
                // 基于准备好的dom，初始化echarts实例
                var myChart = echarts.init(document.getElementById('main'));

                // 指定图表的配置项和数据
                var option = {
                    title: {
                        text: '用户男女比例表格'
                    },
                    tooltip: {},
                    legend: {
                        data:['男女比例']
                    },
                    xAxis: {
                        data: ["男道友","女道友"]
                    },
                    yAxis: {},
                    series: [{
                        name: '男女比例',
                        type: 'bar',
                        data: data.sexDTO
                    }]
                };


                // 基于准备好的dom，初始化echarts实例
                var myChart2 = echarts.init(document.getElementById('main2'));

                // 指定图表的配置项和数据
                var option2 = {
                    title: {
                        text: '近三周用户注册表'
                    },
                    tooltip: {},
                    legend: {
                        data:['注册变化']
                    },
                    xAxis: {
                        data: ["前两周","前一周","本周"]
                    },
                    yAxis: {},
                    series: [{
                        name: '注册变化',
                        type: 'line',
                        data: data.userDTO
                    }]
                };



                var myChart3 = echarts.init(document.getElementById('main3'));

                //    配置地区分布图表数据
                var option3 = {
                    title : {
                        text: '用户地区分布',
                        left: 'center'
                    },
                    tooltip : {
                        trigger: 'item'
                    },
                    legend: {
                        orient: 'vertical',
                        left: 'left',
                        data:['用户人数']
                    },
                    visualMap: {
                        min: 0,
                        max: 25000,
                        left: 'left',
                        top: 'bottom',
                        text:['高','低'],           // 文本，默认为数值文本
                        calculable : true
                    },
                    toolbox: {
                        show: true,
                        orient : 'vertical',
                        left: 'right',
                        top: 'center',
                        feature : {
                            mark : {show: true},
                            dataView : {show: true, readOnly: false},
                            restore : {show: true},
                            saveAsImage : {show: true}
                        }
                    },
                    series : [
                        {
                            name: '用户人数',
                            type: 'map',
                            mapType: 'china',
                            roam: false,
                            label: {
                                normal: {
                                    show: false
                                },
                                emphasis: {
                                    show: true
                                }
                            },
                            data:data.address
                        }
                    ]
                };
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
                myChart2.setOption(option2);
                myChart3.setOption(option3);
            }
        })
    })
</script>


</html>
